package com.yowasa.xiuxian.engine.battle.strategy.drop.all;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.yowasa.xiuxian.annoations.BS;
import com.yowasa.xiuxian.constant.XiuxianConstants;
import com.yowasa.xiuxian.engine.battle.strategy.BaseBattleStrategy;
import com.yowasa.xiuxian.entity.bo.battle.BattleContent;
import com.yowasa.xiuxian.entity.bo.battle.BuffContent;
import com.yowasa.xiuxian.entity.bo.battle.UserBattleContent;
import com.yowasa.xiuxian.entity.bo.user.UserBO;
import com.yowasa.xiuxian.entity.enums.ElementEnum;
import com.yowasa.xiuxian.exception.HandlerException;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;

@BS(name="烈焰焚烬", upAbility = 4, needTravel = 1000)
@Order(1)
@Component
public class FenJing extends BaseBattleStrategy {
    @Override
    public ElementEnum getElement() {
        return ElementEnum.FIRE;
    }
    @Override
    public void action(UserBattleContent first, UserBattleContent second, BattleContent content) {
        BuffContent buffContent = new BuffContent();
        buffContent.setDuration(20);
        buffContent.setNum(1);
        first.getBuff().put("融毁", buffContent);
        first.getFlag().put("烈焰焚烬","1");
        //扣蓝
        first.getBattleInfo().setCmp(first.getBattleInfo().getCmp()-100);
        content.getMsgLog().add(first.getUserBO().getName() + "使用了烈焰焚烬,获得了强化");
    }

    @Override
    public void limit(UserBO user) {
        if (user.getElement().get("火") < XiuxianConstants.DEFAULT_ELEMENT_ACTIVITY) {
            throw new HandlerException("学习/使用烈焰焚烬必须具有火灵根");
        }
    }

    @Override
    public String limitDesc() {
        return "具有火灵根";
    }

    @Override
    public boolean check(UserBattleContent user, BattleContent content) {
        String flag = (String) user.getFlag().get("烈焰焚烬");
        if (StringUtils.isNotBlank(flag)) {
            return false;
        }
        //校验蓝
        if (user.getBattleInfo().getCmp() < 100) {
            return false;
        }
        return true;
    }

    @Override
    public String desc() {
        return "尽可能优先释放，仅会释放一次，蓝耗100点，给自身增加0.2的法术攻击，每降低30%生命值倍率提升0.1，最高提升至0.5，持续20次自己行动";
    }
}
